package com.mazaiting.rtda.heap;

import com.mazaiting.rtda.MtSlots;
import lombok.Getter;
import lombok.Setter;

/**
 * 所有类的父类
 *
 * @author mazaiting
 * @since 2021/8/13
 */
@Setter
@Getter
public class MtObject {
    /**
     * 类实例
     */
    private MtClass mtClass;
    /**
     * 字段数组
     */
    private MtSlots fields;

    public MtObject(MtClass mtClass) {
        this.mtClass = mtClass;
        this.fields = new MtSlots(mtClass.getInstanceSlotCount());
    }

    /**
     * 判断参数类是否当前对象的实例
     *
     * @param mtClass 类实例
     * @return true: 是; false: 非子类实例
     */
    public boolean isInstanceOf(MtClass mtClass) {
        return mtClass.isAssignableFrom(this.mtClass);
    }
}


















